From 344059d3bc43555559bfd3bffd928e00a79c006b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibaut=20VAR=C3=88NE?= Date: Thu, 27 Oct 2022 14:32:30 +0200 Subject: [PATCH] phase1: refactor worker parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Thibaut VARÈNE --- phase1/master.cfg | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index fdbb2cd..53d2098 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -131,27 +131,39 @@ c['buildbotURL'] = inip1.get("buildbot_url") c['workers'] = [] NetLocks = dict() +def ini_parse_workers(section): + name = section.get("name") + password = section.get("password") + phase = section.getint("phase") + + if not name or not password or not phase == 1: + log.msg("invalid worker configuration ignored: {}".format(repr(section))) + return + + sl_props = { 'dl_lock':None, 'ul_lock':None } + if "dl_lock" in section: + lockname = section.get("dl_lock") + sl_props['dl_lock'] = lockname + if lockname not in NetLocks: + NetLocks[lockname] = locks.MasterLock(lockname) + if "ul_lock" in section: + lockname = section.get("ul_lock") + sl_props['ul_lock'] = lockname + if lockname not in NetLocks: + NetLocks[lockname] = locks.MasterLock(lockname) + + log.msg("Configured worker: {}".format(name)) + c['workers'].append(Worker(name, password, max_builds = 1, properties = sl_props)) + + for section in ini.sections(): if section.startswith("branch "): ini_parse_branch(ini[section]) if section.startswith("worker "): - if ini.has_option(section, "name") and ini.has_option(section, "password") and \ - (not ini.has_option(section, "phase") or ini.getint(section, "phase") == 1): - sl_props = { 'dl_lock':None, 'ul_lock':None } - name = ini.get(section, "name") - password = ini.get(section, "password") - if ini.has_option(section, "dl_lock"): - lockname = ini.get(section, "dl_lock") - sl_props['dl_lock'] = lockname - if lockname not in NetLocks: - NetLocks[lockname] = locks.MasterLock(lockname) - if ini.has_option(section, "ul_lock"): - lockname = ini.get(section, "ul_lock") - sl_props['ul_lock'] = lockname - if lockname not in NetLocks: - NetLocks[lockname] = locks.MasterLock(lockname) - c['workers'].append(Worker(name, password, max_builds = 1, properties = sl_props)) + ini_parse_workers(ini[section]) + +branchNames = [branches[b]["name"] for b in branches] c['protocols'] = {'pb': {'port': pb_port}} @@ -255,8 +267,6 @@ c['prioritizeBuilders'] = prioritizeBuilders ####### CHANGESOURCES -branchNames = [branches[b]["name"] for b in branches] - # find targets targets = set() -- 2.30.2